﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReObjectiveQuestionDAL : SyncBase<Model.ReObjectiveQuestion>
    {
        static ReObjectiveQuestionDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReObjectiveQuestionDAL.addSQL = @"insert into TempReObjectiveQuestion(
ArrangeID,StudentID,StudentName,QuestionCombinationID,QuestionID,StemID,QuestionScore,Answer,IsCorrect,ResourceType,AnswerTime)
 values (
@ArrangeID,@StudentID,@StudentName,@QuestionCombinationID,@QuestionID,@StemID,@QuestionScore,@Answer,@IsCorrect,@ResourceType,@AnswerTime)";
            ReObjectiveQuestionDAL.tbName = "TempReObjectiveQuestion";
            ReObjectiveQuestionDAL.remoteUrl = "/Ayyfford/AddReObjectiveQuestion";
            ReObjectiveQuestionDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}),",
                            t.ArrangeID.NullNumber(), t.StudentID.NullNumber(), t.StudentName.NullString(), t.QuestionCombinationID.NullNumber(), t.QuestionID.NullNumber(), t.StemID.NullNumber(), t.QuestionScore.NullNumber(), t.Answer.NullString(), t.IsCorrect ? 1 : 0, t.ResourceType.NullString(), t.AnswerTime.NullDate());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReObjectiveQuestion t)
        {
            SyncBase<Model.ReObjectiveQuestion>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReObjectiveQuestion>.AsyncData();
        }
    }
}
